
#pragma once
#include <boost/asio/steady_timer.hpp>

#include "core/rtmp_media_sink.hpp"
#include "core/flv_media_source.hpp"
#include "media_bridge.hpp"
namespace mms {
    class FlvMediaSource;
    class RtmpToFlv : public MediaBridge {
    public:
        RtmpToFlv(ThreadWorker* worker, const std::string& domain_name, const std::string& app_name, const std::string& stream_name);
        virtual ~RtmpToFlv();
        bool init(std::weak_ptr<MediaSource> origin_source) override;
        bool on_metadata(std::shared_ptr<RtmpMessage> metadata_pkt);
        virtual bool on_audio_packet(std::shared_ptr<RtmpMessage> audio_pkt);
        virtual bool on_video_packet(std::shared_ptr<RtmpMessage> video_pkt);
        void close();
    protected:
        std::atomic_flag closed_ = ATOMIC_FLAG_INIT;
        ThreadWorker* worker_;
        boost::asio::steady_timer check_closable_timer_;
    };
};